﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LabLibary;

namespace LabManager.Models
{
    public class MainModel
    {

        STDBHelper _stDbHelper = new STDBHelper();
        ObjResults _objResult = new ObjResults();

        public MainModel()
        {
            _objResult = new ObjResults();
        }


        public bool Save(ObjResults _result)
        {
            _stDbHelper.CreateDBObjects();

            string _strQuery = "Insert Into XN_Result (Ngay, SID, MayXN, MaXNMay, Ketqua, TGTra) Values (@Ngay, @SID, @MayXN, @MaXNMay, @GiaTri, @TGTra)";
            _stDbHelper.AddParameter("@Ngay", _result.Ngay);
            _stDbHelper.AddParameter("@SID", _result.SID);
            _stDbHelper.AddParameter("@MayXN", _result.May);
            _stDbHelper.AddParameter("@MaXNMay", _result.MaMay);
            _stDbHelper.AddParameter("@GiaTri", _result.GiaTri);
            _stDbHelper.AddParameter("@TGTra", _result.TGTra);
            
            return _stDbHelper.ExecuteNonQuery(_strQuery) > 0;
        }
    }
}